package com.zlm.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 企业规模枚举类
 * @Author: duyufu
 * @Date: 2019/4/24 13:17
 */
public enum CompanyScaleEnum {
	COMPANY_SCALE_PEOPLE_NO_LIMIT(-1,"不限"),
    COMPANY_SCALE_PEOPLE_10(0,"10人以下"),
    COMPANY_SCALE_PEOPLE_50(1,"10-50人"),
    COMPANY_SCALE_PEOPLE_100(2,"50-100人"),
    COMPANY_SCALE_PEOPLE_500(3,"100-500人"),
    COMPANY_SCALE_PEOPLE_1000(4,"500-1000人"),
    COMPANY_SCALE_PEOPLE_BIG_1000(5,"1000人以上");
      
    private Integer code;
    private String name;
      
    private CompanyScaleEnum(Integer code, String name){
        this .code=code;  
        this .name=name;  
    }  
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public static List getCompanyScale(){
    	List list = new ArrayList();
    	Map<String,Object> map;
    	for(CompanyScaleEnum scaleEnum:CompanyScaleEnum.values()){
    		map= new HashMap<String, Object>();
    		map.put("code", scaleEnum.getCode());
    		map.put("name", scaleEnum.getName());
    		list.add(map);
    	}
    	return list;
    } 
    
    
    public static String getNameByCode(Integer code){
    	for(CompanyScaleEnum scaleEnum:CompanyScaleEnum.values()){
    		if(scaleEnum.getCode().equals(code)){
    			return scaleEnum.getName();
    		}
    	}
    	return null;
    } 
    
    public static String getCompanyScaleJsonString(){
    	StringBuilder builder = new StringBuilder("{");
    	for(CompanyScaleEnum scaleEnum:CompanyScaleEnum.values()){
    		builder.append("\""+scaleEnum.getCode()+"\":\""+ scaleEnum.getName()+"\",");
    	}
    	String json=builder.substring(0, builder.length()-1)+"}";
    	return json;
    } 
    
    @Override
    public  String toString(){
       return "[code=" + code + ", name=" + name + "]";
    }  
    

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
}  